// 显示选择头像弹窗
// ignore_for_file: file_names
import 'package:flutter/material.dart';

/// 拍照
Widget getCamera(Function? onCamera) {
  return SizedBox(
    height: 50,
    child: GestureDetector(
        onTap: () {
          onCamera?.call();
        },
        child: Container(
          decoration: const BoxDecoration(
            border: Border(
              bottom: BorderSide(
                color: Colors.grey,
                width: 0.5,
              ),
            ),
          ),
          child: const Row(
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              Icon(Icons.camera_alt),
              SizedBox(
                width: 10,
              ),
              Text("拍照")
            ],
          ),
        )),
  );
}

/// 相册
Widget getLibrary(Function? onLibrary) {
  return SizedBox(
    height: 50,
    child: GestureDetector(
      onTap: () {
        onLibrary?.call();
      },
      child: Container(
        decoration: const BoxDecoration(
            border: Border(
          bottom: BorderSide(
            color: Colors.grey,
            width: 0.5,
          ),
        )),
        child: const Row(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            Icon(Icons.photo_library),
            SizedBox(
              width: 10,
            ),
            Text("相册")
          ],
        ),
      ),
    ),
  );
}

/// 取消
Widget getCancel(BuildContext context) {
  return GestureDetector(
    onTap: () {
      Navigator.pop(context);
    },
    child: const SizedBox(
      height: 50,
      child: Row(
        mainAxisAlignment: MainAxisAlignment.center,
        children: [
          Icon(Icons.cancel),
          SizedBox(
            width: 10,
          ),
          Text("取消")
        ],
      ),
    ),
  );
}

/// 显示弹窗
showCameraDialog(BuildContext context,
    {Function? onCamera, Function? onLibrary}) {
  showModalBottomSheet(
      context: context,
      builder: (context) {
        return Container(
          height: 150,
          width: double.infinity,
          decoration: BoxDecoration(
            borderRadius: BorderRadius.circular(10),
          ),
          child: Column(
            children: [
              getCamera(onCamera),
              getLibrary(onLibrary),
              getCancel(context)
            ],
          ),
        );
      });
}
